﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Mock1G3.BaseEntities;
using System.Data;

namespace Mock1G3.DataAccess
{
    public class TransferCashAccess
    {
        public static decimal GetBalanceAccount(string accountNo)
        {
            return DataAccess.ExeStoredToDecimal("dbo.[usp_BalanceSelectByNo]", "@AccountNo", accountNo);
        }

        public static bool UpdateBalance(string accountNo, decimal amountMoney)
        {
            return DataAccess.ExeStoredWithParamToBool("dbo.[UpDateBalanceByAccountNo]", "@AccountNo", accountNo, "@Balance", amountMoney);
        }

        public static bool TransferCash(string accountNo, string accountReceive, decimal amount)
        {
            return DataAccess.ExeStoredWithParamToBool("dbo.[usp_TransferCash]", "@AccountNoSend", accountNo, "@AccountNoReceive", accountReceive, "@amount", amount);
        }

        public static DataTable GetTransferLimit()
        {
            return DataAccess.ExeStoredNonToDataTable("dbo.[usp_SelectLimitTransfer]");
        }

        public static bool WriteLog(Log log)
        {
            try
            {
                DataAccess.ExeStoredWithParamToBool("dbo.[usp_LogInsertTransfer]", "@ATMID", log.ATMID, "@CardNo", log.CardNo, "@LogDate", log.LogDate, "@Amount", log.Amount, "@Details", log.Detail);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}